package com.muqi.app.qlearn.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.easemob.easeui.widget.CircularImage;
import com.muqi.app.network.http.GlideImageUtils;
import com.muqi.app.project.contants.MContants;
import com.muqi.app.qlearn.modles.PersonBean;
import com.muqi.app.qlearn.modles.StatisticsInfo;
import com.muqi.app.qlearn.modles.StatisticsListInfo;
import com.muqi.app.qlearn.student.R;

import com.muqi.app.user.widget.CircularImageView;
import com.muqi.app.user.widget.SelectableRoundedImageView;

public abstract class CommonAdapter<T> extends BaseAdapter {
	private Context context;
	private List<T> listData;

	private int layoutId;

	public CommonAdapter(Context context, List<T> listData, int layoutId) {
		this.context = context;
		this.listData = listData;
		this.layoutId = layoutId;
	}
	

	public void setListData(List<T> listData) {
		this.listData = listData;
	}


	@Override
	public int getCount() {
		return listData == null ? 10 : listData.size();
	}

	@Override
	public T getItem(int position) {
		return listData.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(layoutId, null);
		}
		T info = listData.get(position);
		convertView(convertView, info);

		return convertView;
	}

	protected abstract void convertView(View item, T t);
}
